package cn.netjava.personblogaction;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.netjava.actioninterface.Action;
import cn.netjava.dao.MsgDao;
import cn.netjava.pojo.User;

public class WriteMsgAction implements Action{

	public String excute(HttpServletRequest request,
			HttpServletResponse response) {
		/*get the user which has logined*/
		HttpSession session =request.getSession();
		User user =(User)session.getAttribute("loginUser");
		
		String msgContent = request.getParameter("msgcontent");
		System.out.println("msgContent:"+msgContent);
		
		int uid = Integer.parseInt(request.getParameter("uid"));
		
		MsgDao mdao =MsgDao.getMsgDao();
		mdao.addMsg(msgContent,user.getId(),uid);
		
		return "personmsg.cn?uid="+uid;
	}

}
